package puppet;
//方法返回多个数据

import java.util.ArrayList;

public class Test {
    public static void main(String[] args) {
        //创建集合
        ArrayList<Phone> list = new ArrayList<>();

        //添加数据
        list.add(new Phone("小米",1000));
        list.add(new Phone("苹果",8000));
        list.add(new Phone("OPPO",2000));

        //查找返回多个值，可使用集合
        ArrayList<Phone> phoneArrayList = getPhone(list);

        for (int i = 0; i < phoneArrayList.size(); i++) {
            Phone phone = phoneArrayList.get(i);
            System.out.println(phone.getBrand() + ", " + phone.getPrice());
        }

    }

    //查询返回多个数据
    public static ArrayList<Phone> getPhone(ArrayList<Phone> list){
        ArrayList<Phone> phoneArrayList = new ArrayList<>();
        for (int i = 0; i < list.size(); i++) {
            Phone phone = list.get(i);
            if(phone.getPrice() < 3000){
                phoneArrayList.add(phone);
            }
        }
        return phoneArrayList;
    }
}
